<template>
	<el-dialog title="系统选择" :visible.sync="dialogVisible" width="900px" @close="handleClose"
		:close-on-click-modal="false" append-to-body="true">
		<div slot="title" class="dialog-header-title">
			<i class="el-icon-edit-outline"></i>
			<span>系统选择</span>
		</div>
		<div class="smp-search">
			<el-form :inline="false" label-width="80px" size="mini" ref="form" :model="form">

				<el-row>
					<el-col :span="24">
						<el-col :span="9">
							<el-form-item label="系统编号:">
								<el-input v-model="query.body.systemNo"></el-input>
							</el-form-item>
						</el-col>

						<el-col :span="9">
							<el-form-item label="系统名称:">
								<el-input v-model="query.body.systemName"></el-input>
							</el-form-item>
						</el-col>


						<el-col :span="6">
							<el-form-item style="text-align: left;">
								<el-button size="mini" type="primary" @click="onSubmit">查询</el-button>
								<el-button size="mini" style="text-align: left;" @click="reset">清空</el-button>
							</el-form-item>
						</el-col>
					</el-col>
				</el-row>
			</el-form>
		</div>

		<div class="smp-result">
			<el-table :data="list" size="mini" stripe border style="width: 100%">
		        <el-table-column prop="systemNo" label="系统编号" width="80" align="center" />
				<el-table-column prop="systemName" label="系统名称" align="center" />
				<!-- <el-table-column prop="systemOrg" label="机构号" width="80" align="center" /> -->
				<!-- <el-table-column prop="systemShort" label="系统简称" width="80" align="center" /> -->
				<el-table-column prop="systemResponsibleMan" label="负责人" width="100" align="center">
					<template slot-scope="scope">
						{{scope.row.systemResponsibleMan|getUserChinesName}}
					</template>
				</el-table-column>
				<!-- <el-table-column prop="testAddr" label="测试应用IP" align="center" />		
				<el-table-column prop="esbAddr" label="关联ESB测试IP" width="150" align="center" />				
				<el-table-column prop="prodAddr" label="生产应用IP"  align="center" />	 -->
 				<!-- <el-table-column prop="associatedRequirement" label="关联需求号" align="center" /> -->
 				<el-table-column prop="msgAgreement" label="默认报文格式" width="100" align="center" />
				<el-table-column prop="msgCode" label="默认报文编码" width="100" align="center">
					<template slot-scope="scope">
						{{scope.row.msgCode|dictName("SMP0004")}}
					</template>
				</el-table-column>
				<el-table-column label="操作" align="center" width="150">
					<template slot-scope="scope">
						<el-link
							size="mini"
							type="primary"
							:underline="false"
							style="font-size: 12px;"
							@click="handleChange(scope.$index, scope.row)">选择</el-link>
					</template>
				</el-table-column>

			</el-table>
		</div>
		<div class="smp-pagination" v-show="total>0">
			<el-pagination background size="medium" layout="total,sizes,prev, pager, next,jumper" :page-size="query.pageSize"
				:page-sizes="[5,10,15]" :total="total" :current-page="query.pageNum" @current-change="currentChange"
				@size-change="sizeChange">
			</el-pagination>

		</div>
	</el-dialog>
</template>

<script>
	"use strict";
	import {
		getSystemInfoByPage
	} from '@/api/service.js';
	export default {

		components: {
		},
		data() {
			return {

				total: 0,

				list: [],

				query: {
					body: {
						systemNo: '',
						systemName: '',
						systemShort: '',
					},
					pageNum: 1,
					pageSize: 10
				},
				dialogVisible:false,
			};



		},

		created() {
			this.getList();
		},

		methods: {


			onSubmit() {
				this.query.pageNum = 1;
				this.getList();
			},


			addSystem() {

				this.$refs.add.showDialog();
			},

			handleEdit(index, row) {
				let row1 = {};
				Object.assign(row1, row);
				this.$refs.edit.showDialog(row1);
			},

			handleDetails(index, row) {
				this.$router.push({
					name: 'systemDetails',
					query: Object.assign(row)
				})
			},

			reset(form) {
				this.query.body = {}
			},

			getList() {
				getSystemInfoByPage(this.query).then(response => {
					this.list = response.data.extend.list
					this.total = response.data.extend.total;

				}).catch(error => {
					console.info("失败");
					console.info(error.message);
				});
			},

			currentChange(val) {
				this.query.pageNum = val;
				this.getList();
			},
			sizeChange(val) {
				this.query.pageSize = val;
				this.query.pageNum = 1;
				this.getList();
			},
			
			
			showDialog() {
				this.dialogVisible = true;
			},
			
			handleChange(index,row){
				this.dialogVisible = false;
				this.$emit("addSystemView",row);
			},
			
			handleClose(){
				this.$emit("resetServer");
			},

		},


	}
</script>

<style>
</style>
